

project, uses(../data_output/termlimited.dta)
project, uses(../data_output/match_analysis_data.dta)

	
	

	use ../data_output/termlimited.dta, clear
	gen log_seniority = log(terms_in_office)
	
	reghdfe pc1 termlimited log_seniority , absorb(CandId chamber_term  ) cluster(CandId)  keepsingletons
	local r1 = _b[termlimited]
	local se1 = _se[termlimited]
	local n1 = e(N)
	local l1 = e(N_clust)
	qui sum pc1 if e(sample)
	local m1 =  abs(r(mean))
	local sd1 = r(sd)		
		
	reghdfe pc1 termlimited  , absorb(CandId  year terms_in_office)  cluster(CandId)	 keepsingletons
	local r2 = _b[termlimited]
	local se2 = _se[termlimited]
	local n2 = e(N)
	local l2 = e(N_clust)
	qui sum pc1 if e(sample)
	local m2 =  abs(r(mean))
	local sd2 = r(sd)	
	
	
	reghdfe pc1 termlimited  , absorb(CandId year cohort_term  )		 cluster(CandId) keepsingletons
	local r3 = _b[termlimited]
	local se3 = _se[termlimited]
	local n3 = e(N)
	local l3 = e(N_clust)	
	qui sum pc1 if e(sample)
	local m3 =  abs(r(mean))
	local sd3 = r(sd)	
	
	

	use ../data_output/match_analysis_data.dta, replace
	
	sum pc
	replace pc = [pc - r(mean) ]/ r(sd) 
	
	
	reghdfe pc termlimited, a(CandId i.MatchId#i.year) cluster(MatchId)
	local r4 = _b[termlimited]
	local se4 = _se[termlimited]
	local n4 = e(N)
	local l4 = e(N_clust)
	qui sum pc if e(sample)
	local m4 =  abs(r(mean))
	local sd4 = r(sd)		
	
	
	cap log close
	quietly {
	
		set linesize 255
		log using "../tables_figures/productivity_robust.tex", text replace
		
		noisily dis "\begin{table}[t]"
		noisily dis "\centering"
		noisily dis "\caption{\textbf{Robustness to Alternative Specifications.}"
		noisily dis "In their final term, term-limited legislators are less productive. \label{tab:robust}} "
		noisily dis "\begin{tabular}{l cccc}"
		noisily dis "\toprule\toprule \\[2mm] "
		noisily dis " & \multicolumn{4}{c}{ Legislative Productivity Index} \\ "
		noisily dis	" \cmidrule(lr){2-5}  \\ "
		noisily dis "& (1) & (2) & (3) & (4)    \\[1mm]"
		noisily dis "\midrule"
		noisily dis " Term Limited  & " %4.2f `r1' " & " %4.2f `r2' " & " %4.2f `r3' " & " %4.2f `r4'    "\\"
		noisily dis "  & (" %4.2f `se1' ") & (" %4.2f `se2' ") & (" %4.2f `se3' ") & (" %4.2f `se4' ")    \\[1mm]"
		noisily dis "\midrule "
		noisily dis " N & " %8.0fc `n1' " & " %8.0fc `n2' " & " %8.0fc `n3' " & " %8.0fc `n4'   "\\"
		noisily dis " Legislators & " %8.0fc `l1' " & " %8.0fc `l2' " & " %8.0fc `l3' " & " %8.0fc `l4'     "\\"
		noisily dis " Outcome Mean  & " %4.2f `m1' " & " %4.2f `m2' " & " %4.2f `m3' " & " %4.2f `m4'   "\\"
		noisily dis " Standard Dev.  & " %4.2f `sd1' " & " %4.2f `sd2' " & " %4.2f `sd3' " & " %4.2f `sd4'     "\\"

		noisily dis "Legislator FE        		 & Yes & Yes 	& Yes & Yes   \\"
		noisily dis "Chamber-Year FE 	  		 & Yes & 	 	&     &  	  \\"
		noisily dis "Year FE 	  				 &     & Yes	&     &  	  \\"
		noisily dis "Log(Seniority) 	 		 & Yes &        &     &		  \\"
		noisily dis "Seniority FE 	 			 &     & Yes    &     &		  \\"
		noisily dis "Cohort-Year FE 	  		 &     &    	& Yes &  	  \\"		
		noisily dis "Matched to NY/TX Legs		 &     & 	    &     &  Yes  \\"
		noisily dis "Match Pair-Year FEs 		 &	   &	    &	  &  Yes  \\"
		
		noisily dis "\bottomrule \bottomrule\\[-4mm]"
		noisily dis "\multicolumn{5}{p{.65\textwidth}}{\footnotesize "
		noisily dis " In all columns the outcome variable is the first principal component from a PCA of the three measures of effort."
		noisily dis "The unit of observation is a legislator. The variable Term Limited is a dummy variable indicating if a legislator is in her final, term-limited term."
		noisily dis "Robust standard clustered by legislator in parentheses.}"
		noisily dis "\end{tabular}"
		noisily dis "\end{table}"
	
		
		log off
	
	}
		
